package com.qeado.admin.dao.ibatis;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.qeado.admin.dao.RoleDao;
import com.qeado.admin.model.Menu;
import com.qeado.admin.model.Role;
import com.qeado.common.dao.BaseDao;

@Repository
@SuppressWarnings("unchecked")
public class RoleDaoImpl extends BaseDao implements RoleDao{

	public void deleteRole(String roleId) {
		getSqlMapClientTemplate().update("deleteRole",roleId);
	}

	public void saveRole(Role roleInfo) {
		getSqlMapClientTemplate().insert("saveRole",roleInfo);
	}
	
	public List<Menu> searchRoleMenuList(String roleId) {
		return (List<Menu>)getSqlMapClientTemplate().queryForList("searchRoleMenuList", roleId);
	}

	public List<Role> searchRole(Role roleInfo) {
		return (List<Role>)getSqlMapClientTemplate().queryForList("searchRole", roleInfo);
	}

	public Role selectRole(String roleId) {
		return (Role)getSqlMapClientTemplate().queryForObject("selectRole",roleId);
	}

	public void updateRole(Role roleInfo) {
		getSqlMapClientTemplate().insert("updateRole",roleInfo);
	}

	public void saveRoleMenu(Map<String, String> map) {
		getSqlMapClientTemplate().insert("saveRoleMenu",map);
	}

	public void deleteRoleMenu(Map<String, String> map) {
		getSqlMapClientTemplate().insert("deleteRoleMenu",map);
	}

	@Override
	public Object searchRoleByName(Role roleInfo) {
		return getSqlMapClientTemplate().queryForObject("searchRoleByName",roleInfo);
	}

}
